
#include "RangedState.h"
#include "..\Game States\GamePlayState.h"
#include "..\Game Objects\Enemy.h"
#include "..\Game Objects\Player.h"
#include "AIPatrolState.h"


RangedState::RangedState()
{
}


RangedState::~RangedState()
{
}

void RangedState::Update(Enemy* enemy, float dt)
{
	enemy->SetAttackTimer(enemy->GetAttackTimer() + dt);

	if (enemy->GetAttackTimer() > enemy->GetAttackResetTime())
	{
		enemy->SetAttackTimer(0.0f);

		SGD::Vector vec = GAME->GetPlayer()->GetPosition() - enemy->GetPosition();
		
		SGD::Point projLoc = SGD::Point(enemy->GetPosition().x, enemy->GetPosition().y - enemy->GetSize().height / 2);

		GAME->CreateProjectile(projLoc, vec, enemy->IsMovingLeft());
	}
}